package com.larry.mr2.etl;

import com.larry.mr2.mapjoin.MapJoinDriver;
import com.larry.mr2.mapjoin.MapJoinMapper;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class WeblogDriver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);

        job.setJarByClass(WeblogDriver.class);

        job.setMapperClass(WeblogMapper.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(NullWritable.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);

        job.setNumReduceTasks(0);
        //设置缓存文件路径
        //job.addCacheFile(URI.create("file:///C:/Users/lishanglai/IdeaProjects/map-reduce/src/main/resources/input3/pd.txt"));

        FileInputFormat.setInputPaths(job,new Path("C:\\Users\\lishanglai\\IdeaProjects\\map-reduce\\src\\main\\resources\\input\\web.log"));
        FileOutputFormat.setOutputPath(job,new Path("C:\\Users\\lishanglai\\IdeaProjects\\map-reduce\\src\\main\\resources\\output"));

        job.waitForCompletion(true);
    }
}
